Analytics database handoff repair (2026-11-03)

What was found:
- The bundled SQLite database contains 6,258 match records.
- The desktop application exposes /api/matches and /api/health.
- Analytics was displaying the disconnected state because its browser-side bridge did not successfully complete the shared database handoff.

Changes:
- Desktop startup now selects an available port if the preferred port is occupied. This prevents a new build from silently colliding with or being confused by a stale app server running on the previous fixed port.
- /api/health now identifies the Football Analytics service and reports its record count/API version.
- Analytics verifies the health endpoint before fetching matches and checks that health/API counts agree; errors are surfaced in the Analytics status text.
- Analytics still uses the combined Plan 1 + Plan 2 evaluator and its active strategy registry integration.

Verification:
- Python syntax checked.
- Local API endpoints tested against the bundled SQLite database; counts should match.
- ZIP integrity checked.
- Browser/mobile runtime and UI interaction still require user-side launch testing.

Important:
- Launch the app using the included startup launcher for this build. If an older instance is open, close it first. The launcher may select a different port when 8766 is occupied; use the address printed by the launcher for phone access.


Follow-up connection stability repair:
- Kept the desktop app on its stable configured port (8766) instead of selecting a different port on each launch.
- This prevents installed shortcuts / PWA links from silently targeting a stale port.
- Analytics connection status now reports the actual origin and record count on success, or the origin and actionable error on failure.
- If port 8766 is already occupied, startup reports the bind failure rather than silently changing the app URL.
- Verification: Python syntax and ZIP integrity checked. Browser/mobile runtime must still be tested on the user's device.


Audit follow-up (2026-11-04)
- Analytics now checks /api/health before /api/matches and rejects record-count mismatches.
- The live status reports the current origin, source row count, active strategy count and qualifying Analytics match count.
- Filter dropdowns use active Manager rules and full source records, even when no match currently qualifies.
- The visible registry empty state distinguishes connection failure, an empty active-rule registry, no triggered matches and filters that return no rows.
